/**
 * 字典接口
 */

import { IDictType, TResponse } from '@/typings'
import { IDictForm } from '@/views/sys/book/type/Form'
import { get, deletes, post } from '..'
import { IBaseVo } from './type'

const prefixUrl = '/sys/dictType/'

export const getDict = (type: string): Promise<TResponse<Array<IDictType>>> => {
  return get(`${prefixUrl}dictByType`, { type })
}

/** 删除字典 */
export const deleteDict = (formId: string): Promise<TResponse<boolean>> => {
  return deletes(`${prefixUrl}del`, { formId })
}

/** 根据id获取字典 */
export const getById = (formId: string): Promise<TResponse<IBaseVo<IDictForm>>> => {
  return get(`${prefixUrl}getById`, { formId })
}

/** 保存字典 */
export const saveDictType = (form: IDictForm): Promise<TResponse<boolean>> => {
  return post(`${prefixUrl}saveDictType`, form)
}
